import {request} from '../request';

const requestRolePre = "/system/role";

// 获取角色列表
export function fetchRoleList(data) {
	return request.post(
		requestRolePre + "/tableData",
		data
	);
}

export function saveOrUpdate(data, state) {
	if (state === 'add') {
		return addRole(data);
	}
	return request.post(
		requestRolePre + "/updateRoleInfo",
		data
	);
}
// 新增角色
export function addRole(data) {
	return request.post(
		requestRolePre + "/add",
		data
	);
}
// 删除角色
export function delRole(data) {
	return request.post(
		requestRolePre + "/delete",
		data
	);
}
// 分配权限
export function assignmentPermission(data){
	return request.post(
		requestRolePre+"/assignmentPermission",
		data
	)
}
// 查看角色
export function viewRole(roleId){
	return request.get(
		requestRolePre+`/view/${roleId}`
	)
}
